<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/admincheck.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('You have no login');window.location.href='login.asp';</script>"
response.End
else
if session("flag")=2 then
response.Write "<p align=center><font color=red>You have not enough level to manage this project!</font></p>"
response.End
end if
end if
%>
<!--#include file="inc/meta.asp"-->
<body>
<%dim selectkey,selectbookid
selectkey=trim(request(trim("selectkey")))
if selectkey="" then
selectkey=request.QueryString("selectkey")
end if
'//
selectbookid=request("selectbookid")
if selectbookid<>"" then
conn.execute "delete from email where id in ("&selectbookid&")"
response.Redirect "email.asp"
response.End
end if
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr> 
		<form name="form1" method="post" action="">
		<td height="100"> 
<%
				Const MaxPerPage=8
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    				if Not isempty(request("page")) then
      				currentPage=Cint(request("page"))
   				else
      				currentPage=1
   				end if 
			set rs=server.CreateObject("adodb.recordset")
			rs.open "select * from email order by id desc",conn,1,1

		   	if err.number<>0 then
				response.write "Sorry, there has no data in database."
				end if
				
  				if rs.eof And rs.bof then
       				Response.Write "<p align='center' class='contents'>Sorry, there has no data in database.</p>"
   				else
	  				totalPut=rs.recordcount

      				if currentpage<1 then
          				currentpage=1
      				end if

      				if (currentpage-1)*MaxPerPage>totalput then
	   					if (totalPut mod MaxPerPage)=0 then
	     					currentpage= totalPut \ MaxPerPage
	   					else
	      					currentpage= totalPut \ MaxPerPage + 1
	   					end if
      				end if

       				if currentPage=1 then
            			showContent
            			showpage totalput,MaxPerPage,"email.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookmark
            				bookmark=rs.bookmark
            				showContent
             				showpage totalput,MaxPerPage,"email.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"email.asp"
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i
	   			i=0
%>

<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  <tr> 
    <td height="25" colspan="6" align="center" background="images/admin_bg_1.gif">
	<b><font color="#ffffff">Email Manage</font></b></td>
  </tr>
<%do while not rs.eof%>
  <tr> 
	<td height="20" width="20%" bgcolor="#E8F1FF" align="right" style="padding-right:10px">
	NO.:</td>
	<td width="15%" bgcolor="#E8F1FF" align="left">
	<strong><%=rs("id")%></strong></td>
	<td width="10%" bgcolor="#E8F1FF" align="right" style="padding-right:10px">
	E-mail:</td>
	<td width="30%" bgcolor="#E8F1FF" align="left">
	<a href=mailto:"<%=rs("email")%>" title="<%=rs("id")%>"><strong><u><%=rs("email")%></u></strong></a></td>
	<td width="20%" bgcolor="#E8F1FF" align="center">Delete
	<input name="selectbookid" type="checkbox" id="selectbookid" value="<%=rs("id")%>"></td>
  </tr>



  <tr>
  	<td bgcolor="#A4BAEA" colspan="6" height="25"></td>
  </tr>

				<%i=i+1
				if i>=MaxPerPage then Exit Do
				rs.movenext
				loop
				rs.close
				set rs=nothing%>
  <tr bgcolor="#E8F1FF"> 
    <td height="30" colspan="5" align="right">Select All
	<input type="checkbox" name="checkbox" value="Check All" onClick="mm()">
	<input type="submit" name="Submit" value="Delete" onClick="return test();">&nbsp;&nbsp;	</td>
  </tr>
</table>
				<%  
				End Sub   
  
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If
				
				Response.Write "<form method=Post action="&filename&">"  
				Response.Write "<p align='center' class='contents'> "  
				If CurrentPage<2 Then  
					Response.Write "<font class='contents'>Home Previous</font> "  
				Else  
					Response.Write "<a href="&filename&"?page=1&class='contents'>Home</a> "  
					Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&class='contents'>Previous</a> "  
				End If
				
				If n-currentpage<1 Then  
					Response.Write "<font class='contents'>Next End</font>"  
				Else  
					Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&class='contents'>"  
					Response.Write "Next</a> <a href="&filename&"?page="&n&"&class='contents'>End</a>"  
				End If  
					Response.Write "<font class='contents'> Pages:</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"</font> "  
					Response.Write "<font class='contents'> Found messages:"&totalnumber&"" 
					Response.Write "<font class='contents'>Turn to </font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">"  
					Response.Write "&nbsp;<input type='submit'  class='contents' value='GO' name='cndok'></form>"  
				End Function  
%>
		</td>
		</form>
	</tr>
</table>
<!--#include file="copyright.asp"-->
</body>
<%call CloseConn()%>
</html>
<script>
function test()
{
  if(!confirm('Are you sure delect that your selected ')) return false;
}
</script>
<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>